#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,b[N];
bool a[N],bj[N];
template<typename T>void read(T &ss)
{
	char ch;ss=0;ch=getchar();
	for (;!isdigit(ch);ch=getchar());
	for (;isdigit(ch);ch=getchar()) ss=(ss<<1)+(ss<<3)+(ch^48);
	return;
}
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	read(n);
	int last=0;
	a[0]=a[1];
	for (int i=1;i<=n;i++) 
	{
		read(a[i]);
		if (a[last]!=a[i])
		{
			b[last]=i;
			last=i;
		}
	}
	int tot=0;
	while (tot<n)
	{
		int j=0;
		while (b[j]!=0)
		{
			int k=b[j];k++;
			tot++,printf("%d ",b[j]),bj[j]=1,j=b[j];
		} 
		bj[j]=1;
		printf("\n");
		last=0;
		for (int i=1;i<=n;i++)
			if (!bj[i]) 
			{
				if (a[last]!=a[i]||!last)
				{
					b[last]=i;
					last=i;
				}
			}
		}	
}

